package com.uni.controller;

import com.uni.pojo.User;
import com.uni.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

import javax.servlet.http.HttpSession;

/**
 * Author: Unirithe
 * Date: 2022/3/26
 **/
@Controller
public class DispatcherController {

    @GetMapping("/")
    public String toDefault(ModelMap modelMap){
        return "login";
    }
    @GetMapping("/index")
    public String index(ModelMap modelMap, HttpSession session){
        User loginUser = (User) session.getAttribute("loginUser");
        modelMap.addAttribute("loginUser", loginUser);
        return "index";
    }
    @GetMapping("/loginout")
    public String loginOut(HttpSession session){
        session.invalidate();
        return "login";
    }

    @GetMapping("/register")
    public String toRegister(){
        return "register";
    }

}
